import 'package:flutter/material.dart';

class BackImageWidget extends StatefulWidget {
  final Widget child;
  final bool isLogin;
  const BackImageWidget({
    super.key,
    required this.child,
    this.isLogin = true,
  });

  @override
  State<BackImageWidget> createState() => _BackImageWidgetState();
}

class _BackImageWidgetState extends State<BackImageWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
        width: MediaQuery.of(context).size.width,
        decoration: BoxDecoration(
            gradient: const LinearGradient(
              begin: Alignment.topCenter, // 渐变起始位置
              end: Alignment.bottomCenter, // 渐变结束位置
              colors: [Color(0xFF313132), Color(0xFF292A31)], // 渐变色数组
            ),
            image: DecorationImage(
              image: AssetImage(widget.isLogin
                  ? 'assets/images/login/background_image_login.png'
                  : 'assets/images/login/background_image.png'), // 背景图
              fit: BoxFit.cover, // 图片填充方式
            )),
        child: widget.child);
  }
}
